package com.mentaleye.controller;

 import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONObject;
import com.mentaleye.bean.WorkTimeBean;
import com.mentaleye.biz.WorkTimeBiz;
import com.mentaleye.util.CommonPage;

@Controller
@RequestMapping(value="/worktime")
public class WorkTimeController {
	
	@RequestMapping(value = "/worktimeList")
	public ModelAndView list() {
        ModelAndView view = new ModelAndView("ss/worktime/worktimeList");
        return view;
    }
	
	@Autowired private  WorkTimeBiz worktimeBiz;
  @RequestMapping(value="/worktimeListData")
  @ResponseBody
   public String worktimeListDate(CommonPage commonPage){
	  worktimeBiz.worktimequeryByPage(commonPage);
	  System.out.println(commonPage.toSHowPage());
	  return commonPage.toSHowPage();
  }
  @RequestMapping(value = "/delete")
  
  public  @ResponseBody String delete(@RequestBody List<Integer> ids){
	  return JSONObject.toJSONString(worktimeBiz.worktimeDelete(ids));
	  
  }
  @RequestMapping(value="/sava")
  public @ResponseBody String sava(  WorkTimeBean worktimebean){
	return JSONObject.toJSONString(worktimeBiz.worktimeAlledit(worktimebean)); 
  }
  @RequestMapping(value="/worktimeEdit")
  public ModelAndView worktimeEdit(@RequestParam(value="worktimeNo",required=false) Integer worktimeNo){
	  ModelAndView view=new ModelAndView("ss/worktime/worktimeEdit");
	  if(worktimeNo!=null){
	   view.addObject("worktime", worktimeBiz.queryWorktimeDate(worktimeNo));
	  }
	  return view;
  }
}
